package org.example.task;

import lombok.Data;
import org.example.task.domain.Task;

@Data
public class Result<T> {
    //200
    private int code;
    //
    private String msg;
    //
    private T data;

    public static Result error() {
        Result result = new Result();
        result.setCode(RsetCodeEnum.ERROR.getCode());
        result.setMsg(RsetCodeEnum.ERROR.getMsg());
        return result;
    }

    public static Result error(String msg) {
        Result result = new Result();
        result.setCode(RsetCodeEnum.ERROR.getCode());
        result.setMsg(msg);
        return result;
    }

    public static <T> Result<T> success(T t) {
        Result<T> result = new Result<>();
        result.setCode(RsetCodeEnum.ERROR.getCode());
        result.setMsg(RsetCodeEnum.SUCCESS.getMsg());
        result.setData(t);
        return result;
    }
}
